blob: 9a16d6db4bedc3cd828969805914c88d15a03151 [file] [log] [blame]
San Mehat64e6a452010-02-04 20:53:48 -08001/*
Jeff Sharkey56bd3122015-04-14 10:30:34 -07002 * Copyright (C) 2015 The Android Open Source Project
San Mehat64e6a452010-02-04 20:53:48 -08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Joe Onoratofe4f3ae2010-06-04 11:25:26 -070017package com.android.systemui.usb;
San Mehat64e6a452010-02-04 20:53:48 -080018
Philip P. Moltmann75b230b2016-04-11 15:27:58 -070019import android.annotation.NonNull;
San Mehat64e6a452010-02-04 20:53:48 -080020import android.app.Notification;
Jeff Sharkey56bd3122015-04-14 10:30:34 -070021import android.app.Notification.Action;
San Mehat64e6a452010-02-04 20:53:48 -080022import android.app.NotificationManager;
23import android.app.PendingIntent;
Jeff Sharkeyd95d3bf2015-04-14 21:39:44 -070024import android.content.BroadcastReceiver;
25import android.content.Context;
San Mehat64e6a452010-02-04 20:53:48 -080026import android.content.Intent;
Jeff Sharkeyd95d3bf2015-04-14 21:39:44 -070027import android.content.IntentFilter;
Jeff Sharkeyb36586a2015-04-27 08:42:28 -070028import android.content.pm.PackageManager;
29import android.content.pm.PackageManager.MoveCallback;
Jeff Sharkey50a05452015-04-29 11:24:52 -070030import android.os.Bundle;
Jeff Sharkeyb36586a2015-04-27 08:42:28 -070031import android.os.Handler;
Dianne Hackborn50cdf7c32012-09-23 17:08:57 -070032import android.os.UserHandle;
Jeff Sharkey56bd3122015-04-14 10:30:34 -070033import android.os.storage.DiskInfo;
San Mehatb1043402010-02-05 08:26:50 -080034import android.os.storage.StorageEventListener;
35import android.os.storage.StorageManager;
Jeff Sharkey56bd3122015-04-14 10:30:34 -070036import android.os.storage.VolumeInfo;
Jeff Sharkeyb36586a2015-04-27 08:42:28 -070037import android.os.storage.VolumeRecord;
38import android.text.TextUtils;
39import android.text.format.DateUtils;
John Spurlockcd686b52013-06-05 10:13:46 -040040import android.util.Log;
Jeff Sharkey50a05452015-04-29 11:24:52 -070041import android.util.SparseArray;
San Mehat64e6a452010-02-04 20:53:48 -080042
Jeff Sharkey56bd3122015-04-14 10:30:34 -070043import com.android.internal.R;
Chris Wren5e6c0ff2017-01-05 12:57:06 -050044import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
John Spurlock3e309b22013-06-25 11:01:29 -040045import com.android.systemui.SystemUI;
Dan Sandler8e032e12017-01-25 13:41:38 -050046import com.android.systemui.util.NotificationChannels;
John Spurlock3e309b22013-06-25 11:01:29 -040047
Jeff Sharkey56bd3122015-04-14 10:30:34 -070048import java.util.List;
49
John Spurlock3e309b22013-06-25 11:01:29 -040050public class StorageNotification extends SystemUI {
San Mehat64e6a452010-02-04 20:53:48 -080051 private static final String TAG = "StorageNotification";
52
Jeff Sharkeyd95d3bf2015-04-14 21:39:44 -070053 private static final String ACTION_SNOOZE_VOLUME = "com.android.systemui.action.SNOOZE_VOLUME";
Jeff Sharkeydf27d3b2015-06-16 13:51:48 -070054 private static final String ACTION_FINISH_WIZARD = "com.android.systemui.action.FINISH_WIZARD";
Jeff Sharkeyd95d3bf2015-04-14 21:39:44 -070055
Jeff Sharkey56bd3122015-04-14 10:30:34 -070056 // TODO: delay some notifications to avoid bumpy fast operations
San Mehat64e6a452010-02-04 20:53:48 -080057
Jeff Sharkey56bd3122015-04-14 10:30:34 -070058 private NotificationManager mNotificationManager;
San Mehatb1043402010-02-05 08:26:50 -080059 private StorageManager mStorageManager;
San Mehat64e6a452010-02-04 20:53:48 -080060
Jeff Sharkey50a05452015-04-29 11:24:52 -070061 private static class MoveInfo {
62 public int moveId;
63 public Bundle extras;
64 public String packageName;
65 public String label;
66 public String volumeUuid;
67 }
68
69 private final SparseArray<MoveInfo> mMoves = new SparseArray<>();
70
Jeff Sharkey56bd3122015-04-14 10:30:34 -070071 private final StorageEventListener mListener = new StorageEventListener() {
72 @Override
73 public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) {
Jeff Sharkeyb36586a2015-04-27 08:42:28 -070074 onVolumeStateChangedInternal(vol);
John Spurlock3e309b22013-06-25 11:01:29 -040075 }
Jeff Sharkeyd95d3bf2015-04-14 21:39:44 -070076
77 @Override
Jeff Sharkey50a05452015-04-29 11:24:52 -070078 public void onVolumeRecordChanged(VolumeRecord rec) {
Jeff Sharkeyd95d3bf2015-04-14 21:39:44 -070079 // Avoid kicking notifications when getting early metadata before
80 // mounted. If already mounted, we're being kicked because of a
81 // nickname or init'ed change.
Jeff Sharkey50a05452015-04-29 11:24:52 -070082 final VolumeInfo vol = mStorageManager.findVolumeByUuid(rec.getFsUuid());
Jeff Sharkeyb36586a2015-04-27 08:42:28 -070083 if (vol != null && vol.isMountedReadable()) {
84 onVolumeStateChangedInternal(vol);
Jeff Sharkeyd95d3bf2015-04-14 21:39:44 -070085 }
Jeff Sharkey50a05452015-04-29 11:24:52 -070086 }
Jeff Sharkeyb36586a2015-04-27 08:42:28 -070087
Jeff Sharkey50a05452015-04-29 11:24:52 -070088 @Override
89 public void onVolumeForgotten(String fsUuid) {
90 // Stop annoying the user
Chris Wren5e6c0ff2017-01-05 12:57:06 -050091 mNotificationManager.cancelAsUser(fsUuid, SystemMessage.NOTE_STORAGE_PRIVATE,
92 UserHandle.ALL);
Jeff Sharkeyb36586a2015-04-27 08:42:28 -070093 }
94
95 @Override
96 public void onDiskScanned(DiskInfo disk, int volumeCount) {
97 onDiskScannedInternal(disk, volumeCount);
Jeff Sharkeyd95d3bf2015-04-14 21:39:44 -070098 }
Philip P. Moltmann75b230b2016-04-11 15:27:58 -070099
100 @Override
101 public void onDiskDestroyed(DiskInfo disk) {
102 onDiskDestroyedInternal(disk);
103 }
Jeff Sharkeyd95d3bf2015-04-14 21:39:44 -0700104 };
105
106 private final BroadcastReceiver mSnoozeReceiver = new BroadcastReceiver() {
107 @Override
108 public void onReceive(Context context, Intent intent) {
109 // TODO: kick this onto background thread
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700110 final String fsUuid = intent.getStringExtra(VolumeRecord.EXTRA_FS_UUID);
111 mStorageManager.setVolumeSnoozed(fsUuid, true);
112 }
113 };
114
Jeff Sharkeydf27d3b2015-06-16 13:51:48 -0700115 private final BroadcastReceiver mFinishReceiver = new BroadcastReceiver() {
116 @Override
117 public void onReceive(Context context, Intent intent) {
118 // When finishing the adoption wizard, clean up any notifications
119 // for moving primary storage
Chris Wren5e6c0ff2017-01-05 12:57:06 -0500120 mNotificationManager.cancelAsUser(null, SystemMessage.NOTE_STORAGE_MOVE,
121 UserHandle.ALL);
Jeff Sharkeydf27d3b2015-06-16 13:51:48 -0700122 }
123 };
124
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700125 private final MoveCallback mMoveCallback = new MoveCallback() {
126 @Override
Jeff Sharkey50a05452015-04-29 11:24:52 -0700127 public void onCreated(int moveId, Bundle extras) {
128 final MoveInfo move = new MoveInfo();
129 move.moveId = moveId;
130 move.extras = extras;
131 if (extras != null) {
132 move.packageName = extras.getString(Intent.EXTRA_PACKAGE_NAME);
133 move.label = extras.getString(Intent.EXTRA_TITLE);
134 move.volumeUuid = extras.getString(VolumeRecord.EXTRA_FS_UUID);
135 }
136 mMoves.put(moveId, move);
137 }
138
139 @Override
140 public void onStatusChanged(int moveId, int status, long estMillis) {
141 final MoveInfo move = mMoves.get(moveId);
142 if (move == null) {
143 Log.w(TAG, "Ignoring unknown move " + moveId);
144 return;
145 }
146
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700147 if (PackageManager.isMoveStatusFinished(status)) {
Jeff Sharkey50a05452015-04-29 11:24:52 -0700148 onMoveFinished(move, status);
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700149 } else {
Jeff Sharkey50a05452015-04-29 11:24:52 -0700150 onMoveProgress(move, status, estMillis);
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700151 }
Jeff Sharkeyd95d3bf2015-04-14 21:39:44 -0700152 }
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700153 };
San Mehat64e6a452010-02-04 20:53:48 -0800154
John Spurlock3e309b22013-06-25 11:01:29 -0400155 @Override
156 public void start() {
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700157 mNotificationManager = mContext.getSystemService(NotificationManager.class);
John Spurlock3e309b22013-06-25 11:01:29 -0400158
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700159 mStorageManager = mContext.getSystemService(StorageManager.class);
160 mStorageManager.registerListener(mListener);
Daniel Sandler5b8743f2010-11-03 09:43:46 -0400161
Jeff Sharkeyd95d3bf2015-04-14 21:39:44 -0700162 mContext.registerReceiver(mSnoozeReceiver, new IntentFilter(ACTION_SNOOZE_VOLUME),
163 android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS, null);
Jeff Sharkeydf27d3b2015-06-16 13:51:48 -0700164 mContext.registerReceiver(mFinishReceiver, new IntentFilter(ACTION_FINISH_WIZARD),
165 android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS, null);
Jeff Sharkeyd95d3bf2015-04-14 21:39:44 -0700166
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700167 // Kick current state into place
Jeff Sharkeyf5a6bd72015-05-19 14:42:38 -0700168 final List<DiskInfo> disks = mStorageManager.getDisks();
169 for (DiskInfo disk : disks) {
170 onDiskScannedInternal(disk, disk.volumeCount);
171 }
172
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700173 final List<VolumeInfo> vols = mStorageManager.getVolumes();
174 for (VolumeInfo vol : vols) {
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700175 onVolumeStateChangedInternal(vol);
176 }
177
178 mContext.getPackageManager().registerMoveCallback(mMoveCallback, new Handler());
179
180 updateMissingPrivateVolumes();
181 }
182
183 private void updateMissingPrivateVolumes() {
184 final List<VolumeRecord> recs = mStorageManager.getVolumeRecords();
185 for (VolumeRecord rec : recs) {
186 if (rec.getType() != VolumeInfo.TYPE_PRIVATE) continue;
187
188 final String fsUuid = rec.getFsUuid();
189 final VolumeInfo info = mStorageManager.findVolumeByUuid(fsUuid);
Jeff Sharkey52fc3c0f2015-06-14 20:58:54 -0700190 if ((info != null && info.isMountedWritable()) || rec.isSnoozed()) {
191 // Yay, private volume is here, or user snoozed
Chris Wren5e6c0ff2017-01-05 12:57:06 -0500192 mNotificationManager.cancelAsUser(fsUuid, SystemMessage.NOTE_STORAGE_PRIVATE,
193 UserHandle.ALL);
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700194
195 } else {
196 // Boo, annoy the user to reinsert the private volume
197 final CharSequence title = mContext.getString(R.string.ext_media_missing_title,
198 rec.getNickname());
199 final CharSequence text = mContext.getString(R.string.ext_media_missing_message);
200
Adrian Roose25c18d2016-06-17 15:59:49 -0700201 Notification.Builder builder = new Notification.Builder(mContext)
Jeff Sharkeya49d5fc2015-05-13 11:40:30 -0700202 .setSmallIcon(R.drawable.ic_sd_card_48dp)
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700203 .setColor(mContext.getColor(R.color.system_notification_accent_color))
204 .setContentTitle(title)
205 .setContentText(text)
Jeff Sharkey50a05452015-04-29 11:24:52 -0700206 .setContentIntent(buildForgetPendingIntent(rec))
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700207 .setStyle(new Notification.BigTextStyle().bigText(text))
208 .setVisibility(Notification.VISIBILITY_PUBLIC)
209 .setLocalOnly(true)
Dan Sandler8e032e12017-01-25 13:41:38 -0500210 .setChannel(NotificationChannels.STORAGE)
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700211 .setCategory(Notification.CATEGORY_SYSTEM)
Adrian Roose25c18d2016-06-17 15:59:49 -0700212 .setDeleteIntent(buildSnoozeIntent(fsUuid));
213 SystemUI.overrideNotificationAppName(mContext, builder);
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700214
Chris Wren5e6c0ff2017-01-05 12:57:06 -0500215 mNotificationManager.notifyAsUser(fsUuid, SystemMessage.NOTE_STORAGE_PRIVATE,
216 builder.build(), UserHandle.ALL);
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700217 }
San Mehat64e6a452010-02-04 20:53:48 -0800218 }
219 }
220
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700221 private void onDiskScannedInternal(DiskInfo disk, int volumeCount) {
Jeff Sharkeyf5a6bd72015-05-19 14:42:38 -0700222 if (volumeCount == 0 && disk.size > 0) {
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700223 // No supported volumes found, give user option to format
224 final CharSequence title = mContext.getString(
Jeff Sharkey52fc3c0f2015-06-14 20:58:54 -0700225 R.string.ext_media_unsupported_notification_title, disk.getDescription());
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700226 final CharSequence text = mContext.getString(
Jeff Sharkey52fc3c0f2015-06-14 20:58:54 -0700227 R.string.ext_media_unsupported_notification_message, disk.getDescription());
San Mehat64e6a452010-02-04 20:53:48 -0800228
Adrian Roose25c18d2016-06-17 15:59:49 -0700229 Notification.Builder builder = new Notification.Builder(mContext)
Dan Sandler8e032e12017-01-25 13:41:38 -0500230 .setChannel(NotificationChannels.STORAGE)
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700231 .setSmallIcon(getSmallIcon(disk, VolumeInfo.STATE_UNMOUNTABLE))
232 .setColor(mContext.getColor(R.color.system_notification_accent_color))
233 .setContentTitle(title)
234 .setContentText(text)
Jeff Sharkey50a05452015-04-29 11:24:52 -0700235 .setContentIntent(buildInitPendingIntent(disk))
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700236 .setStyle(new Notification.BigTextStyle().bigText(text))
237 .setVisibility(Notification.VISIBILITY_PUBLIC)
238 .setLocalOnly(true)
Adrian Roose25c18d2016-06-17 15:59:49 -0700239 .setCategory(Notification.CATEGORY_ERROR);
240 SystemUI.overrideNotificationAppName(mContext, builder);
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700241
Chris Wren5e6c0ff2017-01-05 12:57:06 -0500242 mNotificationManager.notifyAsUser(disk.getId(), SystemMessage.NOTE_STORAGE_DISK,
243 builder.build(), UserHandle.ALL);
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700244
245 } else {
246 // Yay, we have volumes!
Chris Wren5e6c0ff2017-01-05 12:57:06 -0500247 mNotificationManager.cancelAsUser(disk.getId(), SystemMessage.NOTE_STORAGE_DISK,
248 UserHandle.ALL);
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700249 }
250 }
251
Philip P. Moltmann75b230b2016-04-11 15:27:58 -0700252 /**
253 * Remove all notifications for a disk when it goes away.
254 *
255 * @param disk The disk that went away.
256 */
257 private void onDiskDestroyedInternal(@NonNull DiskInfo disk) {
Chris Wren5e6c0ff2017-01-05 12:57:06 -0500258 mNotificationManager.cancelAsUser(disk.getId(), SystemMessage.NOTE_STORAGE_DISK,
259 UserHandle.ALL);
Philip P. Moltmann75b230b2016-04-11 15:27:58 -0700260 }
261
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700262 private void onVolumeStateChangedInternal(VolumeInfo vol) {
263 switch (vol.getType()) {
264 case VolumeInfo.TYPE_PRIVATE:
265 onPrivateVolumeStateChangedInternal(vol);
266 break;
267 case VolumeInfo.TYPE_PUBLIC:
268 onPublicVolumeStateChangedInternal(vol);
269 break;
270 }
271 }
272
273 private void onPrivateVolumeStateChangedInternal(VolumeInfo vol) {
274 Log.d(TAG, "Notifying about private volume: " + vol.toString());
275
276 updateMissingPrivateVolumes();
277 }
278
279 private void onPublicVolumeStateChangedInternal(VolumeInfo vol) {
280 Log.d(TAG, "Notifying about public volume: " + vol.toString());
San Mehat64e6a452010-02-04 20:53:48 -0800281
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700282 final Notification notif;
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700283 switch (vol.getState()) {
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700284 case VolumeInfo.STATE_UNMOUNTED:
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700285 notif = onVolumeUnmounted(vol);
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700286 break;
Jeff Sharkey7e92ef32015-04-17 17:35:07 -0700287 case VolumeInfo.STATE_CHECKING:
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700288 notif = onVolumeChecking(vol);
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700289 break;
290 case VolumeInfo.STATE_MOUNTED:
Jeff Sharkey27de30d2015-04-18 16:20:27 -0700291 case VolumeInfo.STATE_MOUNTED_READ_ONLY:
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700292 notif = onVolumeMounted(vol);
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700293 break;
294 case VolumeInfo.STATE_FORMATTING:
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700295 notif = onVolumeFormatting(vol);
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700296 break;
Jeff Sharkey7e92ef32015-04-17 17:35:07 -0700297 case VolumeInfo.STATE_EJECTING:
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700298 notif = onVolumeEjecting(vol);
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700299 break;
300 case VolumeInfo.STATE_UNMOUNTABLE:
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700301 notif = onVolumeUnmountable(vol);
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700302 break;
303 case VolumeInfo.STATE_REMOVED:
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700304 notif = onVolumeRemoved(vol);
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700305 break;
Jeff Sharkey7e92ef32015-04-17 17:35:07 -0700306 case VolumeInfo.STATE_BAD_REMOVAL:
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700307 notif = onVolumeBadRemoval(vol);
Jeff Sharkey7e92ef32015-04-17 17:35:07 -0700308 break;
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700309 default:
310 notif = null;
311 break;
312 }
313
314 if (notif != null) {
Chris Wren5e6c0ff2017-01-05 12:57:06 -0500315 mNotificationManager.notifyAsUser(vol.getId(), SystemMessage.NOTE_STORAGE_PUBLIC,
316 notif, UserHandle.ALL);
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700317 } else {
Chris Wren5e6c0ff2017-01-05 12:57:06 -0500318 mNotificationManager.cancelAsUser(vol.getId(), SystemMessage.NOTE_STORAGE_PUBLIC,
319 UserHandle.ALL);
San Mehat64e6a452010-02-04 20:53:48 -0800320 }
321 }
322
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700323 private Notification onVolumeUnmounted(VolumeInfo vol) {
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700324 // Ignored
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700325 return null;
San Mehat64e6a452010-02-04 20:53:48 -0800326 }
327
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700328 private Notification onVolumeChecking(VolumeInfo vol) {
Jeff Sharkey27de30d2015-04-18 16:20:27 -0700329 final DiskInfo disk = vol.getDisk();
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700330 final CharSequence title = mContext.getString(
331 R.string.ext_media_checking_notification_title, disk.getDescription());
332 final CharSequence text = mContext.getString(
333 R.string.ext_media_checking_notification_message, disk.getDescription());
San Mehat64e6a452010-02-04 20:53:48 -0800334
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700335 return buildNotificationBuilder(vol, title, text)
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700336 .setCategory(Notification.CATEGORY_PROGRESS)
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700337 .setOngoing(true)
338 .build();
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700339 }
San Mehat64e6a452010-02-04 20:53:48 -0800340
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700341 private Notification onVolumeMounted(VolumeInfo vol) {
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700342 final VolumeRecord rec = mStorageManager.findRecordByUuid(vol.getFsUuid());
Jeff Sharkey27de30d2015-04-18 16:20:27 -0700343 final DiskInfo disk = vol.getDisk();
Makoto Onukib138cb22015-06-23 17:32:02 -0700344
345 // Don't annoy when user dismissed in past. (But make sure the disk is adoptable; we
346 // used to allow snoozing non-adoptable disks too.)
347 if (rec.isSnoozed() && disk.isAdoptable()) {
348 return null;
349 }
350
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700351 if (disk.isAdoptable() && !rec.isInited()) {
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700352 final CharSequence title = disk.getDescription();
353 final CharSequence text = mContext.getString(
354 R.string.ext_media_new_notification_message, disk.getDescription());
San Mehat64e6a452010-02-04 20:53:48 -0800355
Jeff Sharkey50a05452015-04-29 11:24:52 -0700356 final PendingIntent initIntent = buildInitPendingIntent(vol);
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700357 return buildNotificationBuilder(vol, title, text)
Jeff Sharkeya49d5fc2015-05-13 11:40:30 -0700358 .addAction(new Action(R.drawable.ic_settings_24dp,
359 mContext.getString(R.string.ext_media_init_action), initIntent))
360 .addAction(new Action(R.drawable.ic_eject_24dp,
361 mContext.getString(R.string.ext_media_unmount_action),
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700362 buildUnmountPendingIntent(vol)))
Jeff Sharkey50a05452015-04-29 11:24:52 -0700363 .setContentIntent(initIntent)
Jeff Sharkey52fc3c0f2015-06-14 20:58:54 -0700364 .setDeleteIntent(buildSnoozeIntent(vol.getFsUuid()))
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700365 .build();
John Spurlock209bede2013-07-17 12:23:27 -0400366
San Mehat64e6a452010-02-04 20:53:48 -0800367 } else {
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700368 final CharSequence title = disk.getDescription();
369 final CharSequence text = mContext.getString(
370 R.string.ext_media_ready_notification_message, disk.getDescription());
371
Jeff Sharkey50a05452015-04-29 11:24:52 -0700372 final PendingIntent browseIntent = buildBrowsePendingIntent(vol);
Makoto Onukib138cb22015-06-23 17:32:02 -0700373 final Notification.Builder builder = buildNotificationBuilder(vol, title, text)
Jeff Sharkeya49d5fc2015-05-13 11:40:30 -0700374 .addAction(new Action(R.drawable.ic_folder_24dp,
375 mContext.getString(R.string.ext_media_browse_action),
Jeff Sharkey50a05452015-04-29 11:24:52 -0700376 browseIntent))
Jeff Sharkeya49d5fc2015-05-13 11:40:30 -0700377 .addAction(new Action(R.drawable.ic_eject_24dp,
378 mContext.getString(R.string.ext_media_unmount_action),
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700379 buildUnmountPendingIntent(vol)))
Jeff Sharkey50a05452015-04-29 11:24:52 -0700380 .setContentIntent(browseIntent)
Dan Sandler8e032e12017-01-25 13:41:38 -0500381 .setCategory(Notification.CATEGORY_SYSTEM);
Makoto Onukib138cb22015-06-23 17:32:02 -0700382 // Non-adoptable disks can't be snoozed.
383 if (disk.isAdoptable()) {
384 builder.setDeleteIntent(buildSnoozeIntent(vol.getFsUuid()));
385 }
386
387 return builder.build();
San Mehat64e6a452010-02-04 20:53:48 -0800388 }
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700389 }
390
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700391 private Notification onVolumeFormatting(VolumeInfo vol) {
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700392 // Ignored
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700393 return null;
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700394 }
395
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700396 private Notification onVolumeEjecting(VolumeInfo vol) {
Jeff Sharkey27de30d2015-04-18 16:20:27 -0700397 final DiskInfo disk = vol.getDisk();
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700398 final CharSequence title = mContext.getString(
399 R.string.ext_media_unmounting_notification_title, disk.getDescription());
400 final CharSequence text = mContext.getString(
401 R.string.ext_media_unmounting_notification_message, disk.getDescription());
402
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700403 return buildNotificationBuilder(vol, title, text)
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700404 .setCategory(Notification.CATEGORY_PROGRESS)
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700405 .setOngoing(true)
406 .build();
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700407 }
408
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700409 private Notification onVolumeUnmountable(VolumeInfo vol) {
Jeff Sharkey27de30d2015-04-18 16:20:27 -0700410 final DiskInfo disk = vol.getDisk();
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700411 final CharSequence title = mContext.getString(
412 R.string.ext_media_unmountable_notification_title, disk.getDescription());
413 final CharSequence text = mContext.getString(
414 R.string.ext_media_unmountable_notification_message, disk.getDescription());
415
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700416 return buildNotificationBuilder(vol, title, text)
Jeff Sharkey52fc3c0f2015-06-14 20:58:54 -0700417 .setContentIntent(buildInitPendingIntent(vol))
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700418 .setCategory(Notification.CATEGORY_ERROR)
419 .build();
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700420 }
421
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700422 private Notification onVolumeRemoved(VolumeInfo vol) {
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700423 if (!vol.isPrimary()) {
424 // Ignore non-primary media
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700425 return null;
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700426 }
427
Jeff Sharkey27de30d2015-04-18 16:20:27 -0700428 final DiskInfo disk = vol.getDisk();
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700429 final CharSequence title = mContext.getString(
430 R.string.ext_media_nomedia_notification_title, disk.getDescription());
431 final CharSequence text = mContext.getString(
432 R.string.ext_media_nomedia_notification_message, disk.getDescription());
433
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700434 return buildNotificationBuilder(vol, title, text)
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700435 .setCategory(Notification.CATEGORY_ERROR)
436 .build();
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700437 }
438
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700439 private Notification onVolumeBadRemoval(VolumeInfo vol) {
Jeff Sharkey7e92ef32015-04-17 17:35:07 -0700440 if (!vol.isPrimary()) {
441 // Ignore non-primary media
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700442 return null;
Jeff Sharkey7e92ef32015-04-17 17:35:07 -0700443 }
444
Jeff Sharkey27de30d2015-04-18 16:20:27 -0700445 final DiskInfo disk = vol.getDisk();
Jeff Sharkey7e92ef32015-04-17 17:35:07 -0700446 final CharSequence title = mContext.getString(
447 R.string.ext_media_badremoval_notification_title, disk.getDescription());
448 final CharSequence text = mContext.getString(
449 R.string.ext_media_badremoval_notification_message, disk.getDescription());
450
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700451 return buildNotificationBuilder(vol, title, text)
Jeff Sharkey7e92ef32015-04-17 17:35:07 -0700452 .setCategory(Notification.CATEGORY_ERROR)
453 .build();
Jeff Sharkey7e92ef32015-04-17 17:35:07 -0700454 }
455
Jeff Sharkey50a05452015-04-29 11:24:52 -0700456 private void onMoveProgress(MoveInfo move, int status, long estMillis) {
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700457 final CharSequence title;
Jeff Sharkey50a05452015-04-29 11:24:52 -0700458 if (!TextUtils.isEmpty(move.label)) {
459 title = mContext.getString(R.string.ext_media_move_specific_title, move.label);
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700460 } else {
461 title = mContext.getString(R.string.ext_media_move_title);
462 }
463
464 final CharSequence text;
465 if (estMillis < 0) {
466 text = null;
467 } else {
468 text = DateUtils.formatDuration(estMillis);
469 }
470
Jeff Sharkey50a05452015-04-29 11:24:52 -0700471 final PendingIntent intent;
472 if (move.packageName != null) {
473 intent = buildWizardMovePendingIntent(move);
474 } else {
475 intent = buildWizardMigratePendingIntent(move);
476 }
477
Adrian Roose25c18d2016-06-17 15:59:49 -0700478 Notification.Builder builder = new Notification.Builder(mContext)
Jeff Sharkeya49d5fc2015-05-13 11:40:30 -0700479 .setSmallIcon(R.drawable.ic_sd_card_48dp)
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700480 .setColor(mContext.getColor(R.color.system_notification_accent_color))
481 .setContentTitle(title)
482 .setContentText(text)
Jeff Sharkey50a05452015-04-29 11:24:52 -0700483 .setContentIntent(intent)
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700484 .setStyle(new Notification.BigTextStyle().bigText(text))
485 .setVisibility(Notification.VISIBILITY_PUBLIC)
486 .setLocalOnly(true)
Dan Sandler8e032e12017-01-25 13:41:38 -0500487 .setChannel(NotificationChannels.STORAGE)
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700488 .setCategory(Notification.CATEGORY_PROGRESS)
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700489 .setProgress(100, status, false)
Adrian Roose25c18d2016-06-17 15:59:49 -0700490 .setOngoing(true);
491 SystemUI.overrideNotificationAppName(mContext, builder);
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700492
Chris Wren5e6c0ff2017-01-05 12:57:06 -0500493 mNotificationManager.notifyAsUser(move.packageName, SystemMessage.NOTE_STORAGE_MOVE,
Adrian Roose25c18d2016-06-17 15:59:49 -0700494 builder.build(), UserHandle.ALL);
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700495 }
496
Jeff Sharkey50a05452015-04-29 11:24:52 -0700497 private void onMoveFinished(MoveInfo move, int status) {
498 if (move.packageName != null) {
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700499 // We currently ignore finished app moves; just clear the last
500 // published progress
Chris Wren5e6c0ff2017-01-05 12:57:06 -0500501 mNotificationManager.cancelAsUser(move.packageName, SystemMessage.NOTE_STORAGE_MOVE,
502 UserHandle.ALL);
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700503 return;
504 }
505
Jeff Sharkey50a05452015-04-29 11:24:52 -0700506 final VolumeInfo privateVol = mContext.getPackageManager().getPrimaryStorageCurrentVolume();
507 final String descrip = mStorageManager.getBestVolumeDescription(privateVol);
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700508
509 final CharSequence title;
510 final CharSequence text;
511 if (status == PackageManager.MOVE_SUCCEEDED) {
512 title = mContext.getString(R.string.ext_media_move_success_title);
513 text = mContext.getString(R.string.ext_media_move_success_message, descrip);
514 } else {
515 title = mContext.getString(R.string.ext_media_move_failure_title);
516 text = mContext.getString(R.string.ext_media_move_failure_message);
517 }
518
Jeff Sharkey50a05452015-04-29 11:24:52 -0700519 // Jump back into the wizard flow if we moved to a real disk
520 final PendingIntent intent;
521 if (privateVol != null && privateVol.getDisk() != null) {
522 intent = buildWizardReadyPendingIntent(privateVol.getDisk());
Jeff Sharkeyef10ee02015-07-05 14:17:27 -0700523 } else if (privateVol != null) {
Jeff Sharkey50a05452015-04-29 11:24:52 -0700524 intent = buildVolumeSettingsPendingIntent(privateVol);
Jeff Sharkeyef10ee02015-07-05 14:17:27 -0700525 } else {
526 intent = null;
Jeff Sharkey50a05452015-04-29 11:24:52 -0700527 }
528
Adrian Roose25c18d2016-06-17 15:59:49 -0700529 Notification.Builder builder = new Notification.Builder(mContext)
Jeff Sharkeya49d5fc2015-05-13 11:40:30 -0700530 .setSmallIcon(R.drawable.ic_sd_card_48dp)
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700531 .setColor(mContext.getColor(R.color.system_notification_accent_color))
532 .setContentTitle(title)
533 .setContentText(text)
Jeff Sharkey50a05452015-04-29 11:24:52 -0700534 .setContentIntent(intent)
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700535 .setStyle(new Notification.BigTextStyle().bigText(text))
536 .setVisibility(Notification.VISIBILITY_PUBLIC)
537 .setLocalOnly(true)
538 .setCategory(Notification.CATEGORY_SYSTEM)
Dan Sandler8e032e12017-01-25 13:41:38 -0500539 .setChannel(NotificationChannels.STORAGE)
Adrian Roose25c18d2016-06-17 15:59:49 -0700540 .setAutoCancel(true);
541 SystemUI.overrideNotificationAppName(mContext, builder);
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700542
Chris Wren5e6c0ff2017-01-05 12:57:06 -0500543 mNotificationManager.notifyAsUser(move.packageName, SystemMessage.NOTE_STORAGE_MOVE,
544 builder.build(), UserHandle.ALL);
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700545 }
546
547 private int getSmallIcon(DiskInfo disk, int state) {
548 if (disk.isSd()) {
549 switch (state) {
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700550 case VolumeInfo.STATE_CHECKING:
551 case VolumeInfo.STATE_EJECTING:
Jeff Sharkeya49d5fc2015-05-13 11:40:30 -0700552 return R.drawable.ic_sd_card_48dp;
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700553 default:
Jeff Sharkeya49d5fc2015-05-13 11:40:30 -0700554 return R.drawable.ic_sd_card_48dp;
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700555 }
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700556 } else if (disk.isUsb()) {
Jeff Sharkeya49d5fc2015-05-13 11:40:30 -0700557 return R.drawable.ic_usb_48dp;
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700558 } else {
Jeff Sharkeya49d5fc2015-05-13 11:40:30 -0700559 return R.drawable.ic_sd_card_48dp;
Jeff Sharkeye6c04f92015-04-18 21:38:05 -0700560 }
561 }
562
563 private Notification.Builder buildNotificationBuilder(VolumeInfo vol, CharSequence title,
564 CharSequence text) {
Adrian Roose25c18d2016-06-17 15:59:49 -0700565 Notification.Builder builder = new Notification.Builder(mContext)
Dan Sandler8e032e12017-01-25 13:41:38 -0500566 .setChannel(NotificationChannels.STORAGE)
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700567 .setSmallIcon(getSmallIcon(vol.getDisk(), vol.getState()))
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700568 .setColor(mContext.getColor(R.color.system_notification_accent_color))
569 .setContentTitle(title)
570 .setContentText(text)
571 .setStyle(new Notification.BigTextStyle().bigText(text))
572 .setVisibility(Notification.VISIBILITY_PUBLIC)
573 .setLocalOnly(true);
Adrian Roose25c18d2016-06-17 15:59:49 -0700574 overrideNotificationAppName(mContext, builder);
575 return builder;
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700576 }
577
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700578 private PendingIntent buildInitPendingIntent(DiskInfo disk) {
579 final Intent intent = new Intent();
580 intent.setClassName("com.android.settings",
581 "com.android.settings.deviceinfo.StorageWizardInit");
582 intent.putExtra(DiskInfo.EXTRA_DISK_ID, disk.getId());
583
584 final int requestKey = disk.getId().hashCode();
585 return PendingIntent.getActivityAsUser(mContext, requestKey, intent,
586 PendingIntent.FLAG_CANCEL_CURRENT, null, UserHandle.CURRENT);
587 }
588
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700589 private PendingIntent buildInitPendingIntent(VolumeInfo vol) {
590 final Intent intent = new Intent();
591 intent.setClassName("com.android.settings",
592 "com.android.settings.deviceinfo.StorageWizardInit");
Jeff Sharkeyd95d3bf2015-04-14 21:39:44 -0700593 intent.putExtra(VolumeInfo.EXTRA_VOLUME_ID, vol.getId());
594
595 final int requestKey = vol.getId().hashCode();
596 return PendingIntent.getActivityAsUser(mContext, requestKey, intent,
597 PendingIntent.FLAG_CANCEL_CURRENT, null, UserHandle.CURRENT);
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700598 }
599
600 private PendingIntent buildUnmountPendingIntent(VolumeInfo vol) {
601 final Intent intent = new Intent();
602 intent.setClassName("com.android.settings",
603 "com.android.settings.deviceinfo.StorageUnmountReceiver");
Jeff Sharkeyd95d3bf2015-04-14 21:39:44 -0700604 intent.putExtra(VolumeInfo.EXTRA_VOLUME_ID, vol.getId());
605
606 final int requestKey = vol.getId().hashCode();
607 return PendingIntent.getBroadcastAsUser(mContext, requestKey, intent,
608 PendingIntent.FLAG_CANCEL_CURRENT, UserHandle.CURRENT);
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700609 }
610
611 private PendingIntent buildBrowsePendingIntent(VolumeInfo vol) {
612 final Intent intent = vol.buildBrowseIntent();
Jeff Sharkeyd95d3bf2015-04-14 21:39:44 -0700613
614 final int requestKey = vol.getId().hashCode();
615 return PendingIntent.getActivityAsUser(mContext, requestKey, intent,
616 PendingIntent.FLAG_CANCEL_CURRENT, null, UserHandle.CURRENT);
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700617 }
618
Jeff Sharkey50a05452015-04-29 11:24:52 -0700619 private PendingIntent buildVolumeSettingsPendingIntent(VolumeInfo vol) {
Jeff Sharkey56bd3122015-04-14 10:30:34 -0700620 final Intent intent = new Intent();
Jeff Sharkey50a05452015-04-29 11:24:52 -0700621 switch (vol.getType()) {
622 case VolumeInfo.TYPE_PRIVATE:
623 intent.setClassName("com.android.settings",
624 "com.android.settings.Settings$PrivateVolumeSettingsActivity");
625 break;
626 case VolumeInfo.TYPE_PUBLIC:
627 intent.setClassName("com.android.settings",
628 "com.android.settings.Settings$PublicVolumeSettingsActivity");
629 break;
630 default:
631 return null;
632 }
Jeff Sharkeyd95d3bf2015-04-14 21:39:44 -0700633 intent.putExtra(VolumeInfo.EXTRA_VOLUME_ID, vol.getId());
634
635 final int requestKey = vol.getId().hashCode();
636 return PendingIntent.getActivityAsUser(mContext, requestKey, intent,
637 PendingIntent.FLAG_CANCEL_CURRENT, null, UserHandle.CURRENT);
638 }
639
Jeff Sharkey52fc3c0f2015-06-14 20:58:54 -0700640 private PendingIntent buildSnoozeIntent(String fsUuid) {
Jeff Sharkeyd95d3bf2015-04-14 21:39:44 -0700641 final Intent intent = new Intent(ACTION_SNOOZE_VOLUME);
Jeff Sharkey52fc3c0f2015-06-14 20:58:54 -0700642 intent.putExtra(VolumeRecord.EXTRA_FS_UUID, fsUuid);
Jeff Sharkeyd95d3bf2015-04-14 21:39:44 -0700643
Jeff Sharkey52fc3c0f2015-06-14 20:58:54 -0700644 final int requestKey = fsUuid.hashCode();
Jeff Sharkeyd95d3bf2015-04-14 21:39:44 -0700645 return PendingIntent.getBroadcastAsUser(mContext, requestKey, intent,
646 PendingIntent.FLAG_CANCEL_CURRENT, UserHandle.CURRENT);
San Mehat64e6a452010-02-04 20:53:48 -0800647 }
Jeff Sharkeyb36586a2015-04-27 08:42:28 -0700648
649 private PendingIntent buildForgetPendingIntent(VolumeRecord rec) {
650 final Intent intent = new Intent();
651 intent.setClassName("com.android.settings",
652 "com.android.settings.Settings$PrivateVolumeForgetActivity");
653 intent.putExtra(VolumeRecord.EXTRA_FS_UUID, rec.getFsUuid());
654
655 final int requestKey = rec.getFsUuid().hashCode();
656 return PendingIntent.getActivityAsUser(mContext, requestKey, intent,
657 PendingIntent.FLAG_CANCEL_CURRENT, null, UserHandle.CURRENT);
658 }
Jeff Sharkey50a05452015-04-29 11:24:52 -0700659
660 private PendingIntent buildWizardMigratePendingIntent(MoveInfo move) {
661 final Intent intent = new Intent();
662 intent.setClassName("com.android.settings",
663 "com.android.settings.deviceinfo.StorageWizardMigrateProgress");
664 intent.putExtra(PackageManager.EXTRA_MOVE_ID, move.moveId);
665
666 final VolumeInfo vol = mStorageManager.findVolumeByQualifiedUuid(move.volumeUuid);
Suprabh Shuklaaf6c4192016-04-27 14:05:54 -0700667 if (vol != null) {
668 intent.putExtra(VolumeInfo.EXTRA_VOLUME_ID, vol.getId());
669 }
Jeff Sharkey50a05452015-04-29 11:24:52 -0700670 return PendingIntent.getActivityAsUser(mContext, move.moveId, intent,
671 PendingIntent.FLAG_CANCEL_CURRENT, null, UserHandle.CURRENT);
672 }
673
674 private PendingIntent buildWizardMovePendingIntent(MoveInfo move) {
675 final Intent intent = new Intent();
676 intent.setClassName("com.android.settings",
677 "com.android.settings.deviceinfo.StorageWizardMoveProgress");
678 intent.putExtra(PackageManager.EXTRA_MOVE_ID, move.moveId);
679
680 return PendingIntent.getActivityAsUser(mContext, move.moveId, intent,
681 PendingIntent.FLAG_CANCEL_CURRENT, null, UserHandle.CURRENT);
682 }
683
684 private PendingIntent buildWizardReadyPendingIntent(DiskInfo disk) {
685 final Intent intent = new Intent();
686 intent.setClassName("com.android.settings",
687 "com.android.settings.deviceinfo.StorageWizardReady");
688 intent.putExtra(DiskInfo.EXTRA_DISK_ID, disk.getId());
689
690 final int requestKey = disk.getId().hashCode();
691 return PendingIntent.getActivityAsUser(mContext, requestKey, intent,
692 PendingIntent.FLAG_CANCEL_CURRENT, null, UserHandle.CURRENT);
693 }
San Mehat64e6a452010-02-04 20:53:48 -0800694}