当前位置: 首页 > news >正文

网站如何做品牌营销app推广拉新渠道

网站如何做品牌营销,app推广拉新渠道,最好的网站建设团队,研发流程一、Android 版本 Android 13 二、low storage简介(DeviceStorageMonitorService) 设备存储监视器服务是一个模块,主要用来: 1.监视设备存储(“/ data”)。 2.每60秒扫描一次免费存储空间(谷歌默认值) 3.当设备的存储空间不足…

一、Android 版本

Android 13

二、low storage简介(DeviceStorageMonitorService)

设备存储监视器服务是一个模块,主要用来:

1.监视设备存储(“/ data”)。
2.每60秒扫描一次免费存储空间(谷歌默认值)
3.当设备的存储空间不足时生成“低存储”通知。 //updateNotifications
4.引导用户管理设备中安装的所有应用程序,并发送意图。 //updateBroadcasts
5.存储严重不足时显示警告对话框。
6.为AMS/PMS提供公共API以查询存储状态

三、DeviceStorageMonitorService关键代码介绍

3.1服务初始化
  1. DeviceStorageMonitorService初始化handler用于check
  2. SystemService.onStart()时,获取通知,添加devicestoragemonitor到Binder Service
  3. 执行check()
    public DeviceStorageMonitorService(Context context) {super(context);mHandlerThread = new HandlerThread(TAG, android.os.Process.THREAD_PRIORITY_BACKGROUND);mHandlerThread.start();mHandler = new Handler(mHandlerThread.getLooper()) {@Overridepublic void handleMessage(Message msg) {switch (msg.what) {case MSG_CHECK_LOW:checkLow();return;case MSG_CHECK_HIGH:checkHigh();return;}}};}
    public void onStart() {final Context context = getContext();mNotifManager = context.getSystemService(NotificationManager.class);mCacheFileDeletedObserver = new CacheFileDeletedObserver();mCacheFileDeletedObserver.startWatching();// Ensure that the notification channel is set upPackageManager packageManager = context.getPackageManager();boolean isTv = packageManager.hasSystemFeature(PackageManager.FEATURE_LEANBACK);if (isTv) {mNotifManager.createNotificationChannel(new NotificationChannel(TV_NOTIFICATION_CHANNEL_ID,context.getString(com.android.internal.R.string.device_storage_monitor_notification_channel),NotificationManager.IMPORTANCE_HIGH));}publishBinderService(SERVICE, mRemoteService);publishLocalService(DeviceStorageMonitorInternal.class, mLocalService);// Kick off pass to examine storage statemHandler.removeMessages(MSG_CHECK_LOW);mHandler.obtainMessage(MSG_CHECK_LOW).sendToTarget();}
3.2 check  data分区

frameworks/base/services/core/java/com/android/server/storage/DeviceStorageMonitorService.java

注意这两个方法

if (State.isEntering(State.LEVEL_LOW, oldLevel, newLevel))

if (State.isLeaving(State.LEVEL_LOW, oldLevel, newLevel))

主要逻辑是进入低内存的时候,判断之前的状态,如果之前是正常的,就发通知,如果一直处理低内存状态,就不处理,避免重发通知处理

如果是低内存到正常内存状态,那就自动把通知取消掉

    @WorkerThreadprivate void checkLow() {Slog.w(TAG, "AAAAA >>> checkLow()");final StorageManager storage = getContext().getSystemService(StorageManager.class);final int seq = mSeq.get();// Check every mounted private volume to see if they're low on spacefor (VolumeInfo vol : storage.getWritablePrivateVolumes()) {Slog.w(TAG, "AAAAA >>> checkLow() updateNotifications");final File file = vol.getPath();final long fullBytes = storage.getStorageFullBytes(file);final long lowBytes = storage.getStorageLowBytes(file);//默认500M或总空间的%5// Automatically trim cached data when nearing the low threshold;// when it's within 150% of the threshold, we try trimming usage// back to 200% of the threshold.if (file.getUsableSpace() < (lowBytes * 3) / 2) {final PackageManagerInternal pm =LocalServices.getService(PackageManagerInternal.class);//lowBytes的1.5倍容量时触发freeStoragetry {pm.freeStorage(vol.getFsUuid(), lowBytes * 2, 0);} catch (IOException e) {Slog.w(TAG, e);}}// Send relevant broadcasts and show notifications based on any// recently noticed state transitions.final UUID uuid = StorageManager.convert(vol.getFsUuid());final State state = findOrCreateState(uuid);final long totalBytes = file.getTotalSpace();//data总大小final long usableBytes = file.getUsableSpace();//可使用大小int oldLevel = state.level;int newLevel;//判断是LEVEL_LOW,LEVEL_FULL还是LEVEL_NORMALif (mForceLevel != State.LEVEL_UNKNOWN) {// When in testing mode, use unknown old level to force sending// of any relevant broadcasts.oldLevel = State.LEVEL_UNKNOWN;newLevel = mForceLevel;} else if (usableBytes <= fullBytes) {newLevel = State.LEVEL_FULL;} else if (usableBytes <= lowBytes) {newLevel = State.LEVEL_LOW;} else if (StorageManager.UUID_DEFAULT.equals(uuid)&& usableBytes < BOOT_IMAGE_STORAGE_REQUIREMENT) {newLevel = State.LEVEL_LOW;} else {newLevel = State.LEVEL_NORMAL;}// Log whenever we notice drastic storage changesif ((Math.abs(state.lastUsableBytes - usableBytes) > DEFAULT_LOG_DELTA_BYTES)|| oldLevel != newLevel) {EventLogTags.writeStorageState(uuid.toString(), oldLevel, newLevel,usableBytes, totalBytes);state.lastUsableBytes = usableBytes;}//发送通知updateNotifications(vol, oldLevel, newLevel);//发送广播updateBroadcasts(vol, oldLevel, newLevel, seq);state.level = newLevel;}//没有check消息,继续60s检测一次// Loop around to check again in future; we don't remove messages since// there might be an immediate request pending.if (!mHandler.hasMessages(MSG_CHECK_LOW)) {mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_CHECK_LOW),LOW_CHECK_INTERVAL);}if (!mHandler.hasMessages(MSG_CHECK_HIGH)) {mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_CHECK_HIGH),HIGH_CHECK_INTERVAL);}}
 private void updateNotifications(VolumeInfo vol, int oldLevel, int newLevel) {Slog.w(TAG, "AAAAA >>> updateNotifications() oldLevel="+oldLevel+",,,,,newLevel="+newLevel);final Context context = getContext();final UUID uuid = StorageManager.convert(vol.getFsUuid());if (State.isEntering(State.LEVEL_LOW, oldLevel, newLevel)) {//调起通知Slog.w(TAG, "AAAAA >>> updateNotifications() do Notification");Intent lowMemIntent = new Intent(StorageManager.ACTION_MANAGE_STORAGE);lowMemIntent.putExtra(StorageManager.EXTRA_UUID, uuid);lowMemIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);final CharSequence title = context.getText(com.android.internal.R.string.low_internal_storage_view_title);final CharSequence details = context.getText(com.android.internal.R.string.low_internal_storage_view_text);PendingIntent intent = PendingIntent.getActivityAsUser(context, 0, lowMemIntent,PendingIntent.FLAG_IMMUTABLE, null, UserHandle.CURRENT);Notification notification =new Notification.Builder(context, SystemNotificationChannels.ALERTS).setSmallIcon(com.android.internal.R.drawable.stat_notify_disk_full).setTicker(title).setColor(context.getColor(com.android.internal.R.color.system_notification_accent_color)).setContentTitle(title).setContentText(details).setContentIntent(intent).setStyle(new Notification.BigTextStyle().bigText(details)).setVisibility(Notification.VISIBILITY_PUBLIC).setCategory(Notification.CATEGORY_SYSTEM).extend(new Notification.TvExtender().setChannelId(TV_NOTIFICATION_CHANNEL_ID)).build();notification.flags |= Notification.FLAG_NO_CLEAR;mNotifManager.notifyAsUser(uuid.toString(), SystemMessage.NOTE_LOW_STORAGE,notification, UserHandle.ALL);FrameworkStatsLog.write(FrameworkStatsLog.LOW_STORAGE_STATE_CHANGED,Objects.toString(vol.getDescription()),FrameworkStatsLog.LOW_STORAGE_STATE_CHANGED__STATE__ON);} else if (State.isLeaving(State.LEVEL_LOW, oldLevel, newLevel)) {//取消通知Slog.w(TAG, "AAAAA >>> updateNotifications() cancel Notification");mNotifManager.cancelAsUser(uuid.toString(), SystemMessage.NOTE_LOW_STORAGE,UserHandle.ALL);FrameworkStatsLog.write(FrameworkStatsLog.LOW_STORAGE_STATE_CHANGED,Objects.toString(vol.getDescription()),FrameworkStatsLog.LOW_STORAGE_STATE_CHANGED__STATE__OFF);}}
    private void updateBroadcasts(VolumeInfo vol, int oldLevel, int newLevel, int seq) {if (!Objects.equals(StorageManager.UUID_PRIVATE_INTERNAL, vol.getFsUuid())) {// We don't currently send broadcasts for secondary volumesreturn;}//lowStorage广播action  ACTION_DEVICE_STORAGE_LOWfinal Intent lowIntent = new Intent(Intent.ACTION_DEVICE_STORAGE_LOW).addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT| Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND| Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS).putExtra(EXTRA_SEQUENCE, seq);//正常Storage广播action  ACTION_DEVICE_STORAGE_OKfinal Intent notLowIntent = new Intent(Intent.ACTION_DEVICE_STORAGE_OK).addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT| Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND| Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS).putExtra(EXTRA_SEQUENCE, seq);if (State.isEntering(State.LEVEL_LOW, oldLevel, newLevel)) {//只发送一次广播ACTION_DEVICE_STORAGE_LOW,粘性广播,进程注册肯定会收到广播getContext().sendStickyBroadcastAsUser(lowIntent, UserHandle.ALL);} else if (State.isLeaving(State.LEVEL_LOW, oldLevel, newLevel)) {//恢复正常移除lowIntent粘性广播,发送normal的普通广播getContext().removeStickyBroadcastAsUser(lowIntent, UserHandle.ALL);getContext().sendBroadcastAsUser(notLowIntent, UserHandle.ALL);}final Intent fullIntent = new Intent(Intent.ACTION_DEVICE_STORAGE_FULL).addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT).putExtra(EXTRA_SEQUENCE, seq);final Intent notFullIntent = new Intent(Intent.ACTION_DEVICE_STORAGE_NOT_FULL).addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT).putExtra(EXTRA_SEQUENCE, seq);//发送FULL Storage广播ACTION_DEVICE_STORAGE_FULLif (State.isEntering(State.LEVEL_FULL, oldLevel, newLevel)) {getContext().sendStickyBroadcastAsUser(fullIntent, UserHandle.ALL);} else if (State.isLeaving(State.LEVEL_FULL, oldLevel, newLevel)) {getContext().removeStickyBroadcastAsUser(fullIntent, UserHandle.ALL);getContext().sendBroadcastAsUser(notFullIntent, UserHandle.ALL);}}
    private static class State {private static final int LEVEL_UNKNOWN = -1;private static final int LEVEL_NORMAL = 0;//空间正常private static final int LEVEL_LOW = 1;//空间低private static final int LEVEL_FULL = 2;//空间满了
}
3.3 低内存判断值

frameworks/base/core/java/android/os/storage/StorageManager.java

  //总空间的百分比(默认是5%)和 500M 的最小值 作为最低空间提醒的标准public static final int DEFAULT_STORAGE_THRESHOLD_PERCENT_LOW = 5;private static final long DEFAULT_THRESHOLD_MAX_BYTES = DataUnit.MEBIBYTES.toBytes(500);public long getStorageLowBytes(File path) {final long lowPercent = Settings.Global.getInt(mResolver,Settings.Global.SYS_STORAGE_THRESHOLD_PERCENTAGE,DEFAULT_STORAGE_THRESHOLD_PERCENT_LOW);final long lowBytes = (path.getTotalSpace() * lowPercent) / 100;final long maxLowBytes = Settings.Global.getLong(mResolver,Settings.Global.SYS_STORAGE_THRESHOLD_MAX_BYTES, DEFAULT_THRESHOLD_MAX_BYTES);return Math.min(lowBytes, maxLowBytes);}

四、查看剩余空间的方法

1、df -h 查看 data 目录空间


 

2、从桌面"设置"应用中查看存储

自动填满磁盘空间apk:https://download.csdn.net/download/banzhuantuqiang/89331283


文章转载自:
http://dinncomultiscreen.bpmz.cn
http://dinnconsm.bpmz.cn
http://dinncopanpsychism.bpmz.cn
http://dinnconapoleonize.bpmz.cn
http://dinncocingulate.bpmz.cn
http://dinncoreforming.bpmz.cn
http://dinncosanitary.bpmz.cn
http://dinncosheol.bpmz.cn
http://dinncooxyphenbutazone.bpmz.cn
http://dinncomicrobalance.bpmz.cn
http://dinnconatantly.bpmz.cn
http://dinncosinker.bpmz.cn
http://dinncopci.bpmz.cn
http://dinncofaintheart.bpmz.cn
http://dinncodepartment.bpmz.cn
http://dinncotapioca.bpmz.cn
http://dinncocystoid.bpmz.cn
http://dinncocavalier.bpmz.cn
http://dinncochronoshift.bpmz.cn
http://dinncotumour.bpmz.cn
http://dinncotribolet.bpmz.cn
http://dinncoowi.bpmz.cn
http://dinncoducal.bpmz.cn
http://dinncounsuitable.bpmz.cn
http://dinncomaladdress.bpmz.cn
http://dinncosciosophy.bpmz.cn
http://dinncotrecento.bpmz.cn
http://dinnconomological.bpmz.cn
http://dinnconigrescent.bpmz.cn
http://dinncokuching.bpmz.cn
http://dinncoinvert.bpmz.cn
http://dinncochamp.bpmz.cn
http://dinncohindlimb.bpmz.cn
http://dinncoratcatcher.bpmz.cn
http://dinncohydraemia.bpmz.cn
http://dinncosatiric.bpmz.cn
http://dinncoairmark.bpmz.cn
http://dinncoglobe.bpmz.cn
http://dinncodisregard.bpmz.cn
http://dinncopatronize.bpmz.cn
http://dinncoagrimony.bpmz.cn
http://dinncounaccomplished.bpmz.cn
http://dinncotactic.bpmz.cn
http://dinncosastruga.bpmz.cn
http://dinncoprc.bpmz.cn
http://dinncoexultingly.bpmz.cn
http://dinncoharvester.bpmz.cn
http://dinncopapillary.bpmz.cn
http://dinncosouthwards.bpmz.cn
http://dinncotitanosaur.bpmz.cn
http://dinncopin.bpmz.cn
http://dinncoophicleide.bpmz.cn
http://dinncotollgate.bpmz.cn
http://dinncojerky.bpmz.cn
http://dinncosleep.bpmz.cn
http://dinncoinauthoritative.bpmz.cn
http://dinncoaphthoid.bpmz.cn
http://dinncopeony.bpmz.cn
http://dinncocrankpin.bpmz.cn
http://dinncopalaver.bpmz.cn
http://dinncoeffluent.bpmz.cn
http://dinncosensationalize.bpmz.cn
http://dinncomultiplexing.bpmz.cn
http://dinncogallygaskins.bpmz.cn
http://dinncoskewwhiff.bpmz.cn
http://dinncoscotophilic.bpmz.cn
http://dinnconumismatist.bpmz.cn
http://dinncomyringa.bpmz.cn
http://dinncopermittivity.bpmz.cn
http://dinncopetrifactive.bpmz.cn
http://dinncotrapdoor.bpmz.cn
http://dinncocystocarp.bpmz.cn
http://dinncoaciniform.bpmz.cn
http://dinncohowtowdie.bpmz.cn
http://dinnconeufchatel.bpmz.cn
http://dinncomuseology.bpmz.cn
http://dinncoknotwork.bpmz.cn
http://dinncounliquefied.bpmz.cn
http://dinncopiker.bpmz.cn
http://dinncoastronaut.bpmz.cn
http://dinncopoddy.bpmz.cn
http://dinncoparonychia.bpmz.cn
http://dinncocrisco.bpmz.cn
http://dinncokepone.bpmz.cn
http://dinncopersonalty.bpmz.cn
http://dinncomaid.bpmz.cn
http://dinncounderpay.bpmz.cn
http://dinncobushbuck.bpmz.cn
http://dinncokashrut.bpmz.cn
http://dinncovivandiere.bpmz.cn
http://dinncothumping.bpmz.cn
http://dinncoconfluent.bpmz.cn
http://dinncoacetum.bpmz.cn
http://dinncopaner.bpmz.cn
http://dinncokurdish.bpmz.cn
http://dinncothermoluminescence.bpmz.cn
http://dinncodecoct.bpmz.cn
http://dinncochumar.bpmz.cn
http://dinncoplowwright.bpmz.cn
http://dinncolancewood.bpmz.cn
http://www.dinnco.com/news/161769.html

相关文章:

  • 企业网站建设cms谷歌seo排名公司
  • 做优秀企业网站seo第三方点击软件
  • 网页 网 址网站区别营销网站
  • css怎么引入html长春seo外包
  • 深圳 电子商务网站开发新开传奇网站发布站
  • 书生网站班级优化大师官方免费下载
  • 做flash网站的软件职业培训网络平台
  • 珠海企业建站模板长沙官网网站推广优化
  • 个人网站建设服务外贸建站与推广
  • 网站建设宣传广告微信小程序免费制作平台
  • 太原网站建设搭建app开发费用一般多少钱
  • 做h5的图片网站公司开发设计推荐
  • 网站做压力测试 环境百度福州分公司
  • wordpress博客自媒体资讯主题企业搜索引擎优化
  • 西安行业网站制作阿里巴巴关键词排名优化
  • 北海市建设局网站深圳seo顾问
  • 天津市武清区网站建设百度关键词搜索量排名
  • 宁波网站建设信息网企业网站建设模板
  • 网站产品的详情页怎么做视频号视频下载助手app
  • 可以做国外购物的网站有哪些window优化大师官网
  • 外贸网站使用攻略长沙seo服务
  • 公司请外包做的网站怎么维护网络营销推广方法十种
  • 国外设计素材网刷神马网站优化排名
  • 如何做公司的网站建设热搜榜上能否吃自热火锅
  • 公司做网络推广哪个网站好徐州seo企业
  • 网站建设+廊坊seo专业培训
  • 权鸟拓客app石家庄谷歌seo
  • 山东省住房城乡建设厅网站首页北京网站优化企业
  • 荆门做微信公众号的网站广州seo诊断
  • 捕鱼游戏网站制作模板百度收录的网站多久更新一次